Attribute VB_Name = "Module1"
Option Explicit
Global icdev As Integer
Global ihdevs(10) As Integer '存放多个设备句柄的数组
Global st As Integer


'comm function
Declare Function fw_init Lib "umf.dll" (ByVal port As Integer, ByVal baud As Long) As Integer
Declare Function fw_exit Lib "umf.dll" (ByVal icdev As Long) As Integer
Declare Function fw_request Lib "umf.dll" (ByVal icdev As Long, ByVal mode%, tagtype As Long) As Integer
Declare Function fw_anticoll Lib "umf.dll" (ByVal icdev As Long, ByVal bcnt%, snr As Long) As Integer
Declare Function fw_select Lib "umf.dll" (ByVal icdev As Long, ByVal snr As Long, size As Byte) As Integer
Declare Function fw_card Lib "umf.dll" (ByVal icdev As Long, ByVal mode%, snr As Long) As Integer
Declare Function fw_load_key Lib "umf.dll" (ByVal icdev As Long, ByVal mode%, ByVal secnr%, ByRef nkey As Byte) As Integer
Declare Function fw_authentication Lib "umf.dll" (ByVal icdev As Long, ByVal mode%, ByVal scenr%) As Integer
Declare Function fw_read Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, ByRef sdata As Byte) As Integer
Declare Function fw_write Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, ByRef sdata As Byte) As Integer
Declare Function fw_changeb3 Lib "umf.dll" (ByVal adr As Long, ByVal secer As Integer, ByRef KeyA As Byte, ByRef Ctrlbytes As Byte, ByVal Bk As Integer, ByRef KeyB As Byte) As Integer



Declare Function fw_HL_initval Lib "umf.dll" (ByVal icdev As Long, ByVal mode As Integer, ByVal adr%, ByVal value As Long, ByRef snr As Long) As Integer
Declare Function fw_HL_increment Lib "umf.dll" (ByVal icdev As Long, ByVal mode As Integer, ByVal adr%, ByVal value As Long, ByVal snr As Long, value As Long, ByRef snr As Long) As Integer
Declare Function fw_HL_decrement Lib "umf.dll" (ByVal icdev As Long, ByVal mode As Integer, ByVal adr%, ByVal value As Long, ByVal snr As Long, value As Long, ByRef snr As Long) As Integer

'
Declare Function fw_initval Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, ByVal value As Long) As Integer
Declare Function fw_readval Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, value As Long) As Integer
Declare Function fw_increment Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, ByVal value As Long) As Integer
Declare Function fw_decrement Lib "umf.dll" (ByVal icdev As Long, ByVal adr%, ByVal value As Long) As Integer
Declare Function fw_restore Lib "umf.dll" (ByVal icdev As Long, ByVal adr%) As Integer
Declare Function fw_transfer Lib "umf.dll" (ByVal icdev As Long, ByVal adr%) As Integer
Declare Function fw_halt Lib "umf.dll" (ByVal icdev As Long) As Integer
Declare Function a_hex Lib "umf.dll" (ByRef abuf As Byte, ByRef hexbuf As Byte, ByVal alen%) As Integer
Public Declare Sub hex_a Lib "umf.dll" (ByRef hexbuf As Byte, ByRef abuf As Byte, ByVal hexlen%)
Declare Function fw_config_card Lib "umf.dll" (ByVal icdev As Long, ByVal cardtype%) As Integer
 

'device fuction
Declare Function fw_gettime Lib "umf.dll" (ByVal icdev As Long, ctime As Byte) As Integer
Declare Function fw_settime Lib "umf.dll" (ByVal icdev As Long, ctime As Byte) As Integer


Declare Function fw_reset Lib "umf.dll" (ByVal icdev As Long, ByVal msec%) As Integer
Declare Function fw_beep Lib "umf.dll" (ByVal icdev As Long, ByVal time1 As Integer) As Integer

'CPU/SAM functions
Declare Function fw_setcpu Lib "umf.dll" (ByVal icdev As Long, ByVal flag%) As Integer
Declare Function fw_cpureset Lib "umf.dll" (ByVal icdev As Long, ByRef relen As Byte, ByRef rdata As Byte) As Integer
Declare Function fw_cpuapdu Lib "umf.dll" (ByVal icdev As Long, ByVal sendlen%, ByRef sdata As Byte, ByRef relen As Byte, ByRef rdata As Byte) As Integer

'非接CPU functions
Declare Function fw_pro_reset Lib "umf.dll" (ByVal icdev As Long, ByRef relen As Byte, ByRef rdata As Byte) As Integer
Declare Function fw_pro_commandlink Lib "umf.dll" (ByVal icdev As Long, ByVal sendlen%, ByRef sdata As Byte, ByRef relen As Byte, ByRef rdata As Byte, ByVal ftt%, ByVal ffg%) As Integer


'ICode funcitons
Declare Function fw_inventory Lib "umf.dll" (ByVal icdev As Long, ByVal flag As Byte, ByVal AFI As Byte, ByVal masklen As Byte, ByRef relen As Byte, ByRef rbuffer As Byte) As Integer
Declare Function fw_stay_quiet Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByRef pUID As Byte) As Integer
Declare Function fw_select_uid Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByRef pUID As Byte) As Integer
Declare Function fw_reset_to_ready Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByRef pUID As Byte) As Integer
Declare Function fw_readblock Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByVal startblock As Byte, ByVal blocknum As Byte, ByRef pUID As Byte, ByRef rlen As Byte, ByRef revbuf As Byte) As Integer
Declare Function fw_writeblock Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByVal startblock As Byte, ByVal blocknum As Byte, ByRef pUID As Byte, ByVal wlen As Byte, ByRef rbuf As Byte) As Integer
Declare Function fw_lock_block Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByVal block As Byte, ByRef pUID As Byte) As Integer
Declare Function fw_write_afi Lib "umf.dll" (ByVal icdev As Long, ByVal AFI As Byte, ByRef pUID As Byte) As Integer
Declare Function fw_lock_afi Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByVal AFI As Byte, ByRef pUID As Byte) As Integer
Declare Function fw_write_dsfid Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByVal DSFID As Byte, ByRef pUID As Byte) As Integer
Declare Function fw_lock_dsfid Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByVal DSFID As Byte, ByRef pUID As Byte) As Integer
Declare Function fw_get_systeminfo Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByRef pUID As Byte, ByRef rlen As Byte, ByRef revbuf As Byte) As Integer
Declare Function fw_get_securityinfo Lib "umf.dll" (ByVal icdev As Long, ByVal flags As Byte, ByVal startblock As Byte, ByVal blocknum As Byte, ByRef pUID As Byte, ByRef rlen As Byte, ByRef rbuf As Byte) As Integer





Sub quit()
    If icdev > 0 Then
       st = fw_exit(icdev)
       icdev = -1
    End If
End Sub


